from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token

from users import views
from .views import UserNameValid,MobileValid
from users.views import UserSaveAPIView,UserDetailView
urlpatterns = [
    url(r'^usernames/(?P<username>\w{5,20})/count/$',UserNameValid.as_view()),
    url(r'^mobiles/(?P<mobile>1[3-9]\d{9})/count/$',MobileValid.as_view()),
    url(r'^users/$',UserSaveAPIView.as_view()),
    # url(r'^authorizations/$',obtain_jwt_token),
    url(r'^authorizations/$',views.UserAuthorizeView.as_view()),
    url(r'^user/$',UserDetailView.as_view()),
    url(r'^email/$',views.EmailView.as_view()),
    url(r'^emails/verification/$',views.VerifyEmailView.as_view()),
    url(r'^browse_histories/$',views.BrowseHistoryView.as_view()),

    url(r'^user/(?P<user_id>\d+)/password/$',views.UpdateUserPWView.as_view()),# 修改密码

    # url(r'^image_codes/(?P<pk>.+)/$', views.GenerateImageCodeView.as_view()),
    url(r'^accounts/(?P<username>.+)/sms/token/$', views.FindMobileView.as_view()), #
    url(r'sms_codes/$', views.SMSCodeView.as_view()),
    url(r'^accounts/(?P<username>.+)/password/token/$', views.VerifySmscodeView.as_view()),
    url(r'^users/(?P<pk>\d+)/password/$', views.SavePasswordView.as_view()),
    # url(r'^user/(?P<user_id>\d+)/password/$', views.UpdatePasswordView.as_view()),
]

from rest_framework.routers import DefaultRouter
router = DefaultRouter()
router.register('addresses',views.AddressViewSet,base_name='address')
urlpatterns+=router.urls